package com.xue.controller;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.xue.bean.UserBean;
import com.xue.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @program: springboot-outbreak
 * @description: 登陆
 * @create: 2020-05-29 17:04
 **/
@Controller
public class LoginController {

    @Autowired
    private LoginService loginService;

    @GetMapping("/login")
    public String login(){
        return "login";
    }

    @PostMapping("/login")
    public String login(@RequestParam("username") String username,@RequestParam("password") String passeord){

        UserBean userBean = loginService.login(username, passeord);
        if(!StringUtils.isEmpty(username) && passeord.equals(userBean.getPassword())){
            return "allList";
        }
        return "login";
    }
}
